
# 导入基类
from base.base import Base
from selenium.webdriver.common.by import By
from time import sleep

# 导入页面类继承基类
class PinPaiPage(Base):

    # 定位商品管理
    goodsmanager = (By.XPATH, '//span[text()="商场管理"]')
    def clickgoodsmanager(self):
        self.loc_ele(self.goodsmanager).click()
    # 定位品牌制作商
    pinpai = (By.XPATH, '//span[text()="品牌制造商"]')
    def clickpinpai(self):
        self.loc_ele(self.pinpai).click()
    # 定位添加品牌制造商的按钮
    tianjiabutton  = (By.CSS_SELECTOR, '#app > div > div.main-container > section > div > div.filter-container > button:nth-child(4) > span')
    def clicktianjiabutton(self):
        self.loc_ele(self.tianjiabutton).click()

    # 定位问题输入框
    proleminput = (By.CLASS_NAME, "el-input__inner")
    def inputprolemcontent(self, c):
        eles = self.loc_eles(self.proleminput)
        ele = eles[3]
        ele.send_keys(c)

    # # 定位回复输入框
    # inputreplycontent = (By.CLASS_NAME, "el-textarea__inner")
    # def inputreplycontentbusiness(self, c):
    #     ele = self.loc_ele(self.inputreplycontent)
    #     ele.send_keys(c)

    # 定位确定按钮
    ensurebutton  = (By.XPATH, '//span[text()="确定"]')
    def clickensurebutton(self):
        self.loc_ele(self.ensurebutton).click()

    # 断言用到的元素
    dy = (By.XPATH, '//table[@class="el-table__body"]/tbody/tr[1]/td[2]/div')
    def getdycontent(self):
        return self.loc_ele(self.dy).text

    # 断言用到的元素
    dy2 = (By.CLASS_NAME, "el-form-item__error")
    def getdy2content(self):
        return self.loc_ele(self.dy2).text

    # 操作业务的方法
    def tianjiabusiness(self, q, r):
        # 点击商品管理
        self.clickgoodsmanager()
        sleep(1)
        # 点击品牌制造商菜单
        self.clickpinpai()
        sleep(1)
        # 点击添加按钮
        self.clicktianjiabutton()
        # 输入品牌商
        self.inputprolemcontent(q)
        # 输入介绍
        # self.inputreplycontentbusiness(r)
        # 输入低价
        sleep(2)
        # 点击确定按钮
        self.clickensurebutton()
        sleep(3)